package cn.lingyangwl.agile.misc.order.controller;

import cn.lingyangwl.agile.misc.order.model.*;
import cn.lingyangwl.agile.misc.order.service.*;
import cn.lingyangwl.framework.core.response.*;
import cn.lingyangwl.framework.validation.group.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单详情
 * 
 * @author shenguangyang
 */
@Api(tags = "订单详情")
@RestController
@RequestMapping("/orderDetail")
public class OrderDetailController {
    @Resource
    private OrderDetailService orderDetailService;

    @ApiOperation(value = "分页订单详情")
    @GetMapping("/page")
    public Resp<IPage<OrderDetailResp>> pageOrderDetail(@Validated OrderDetailQueryReq req) {
        return Resp.ok(orderDetailService.pageOrderDetail(req));
    }

    @ApiOperation(value = "通过id查找订单详情")
    @GetMapping("/get")
    public Resp<OrderDetailResp> getOrderDetail(@RequestParam(value = "id") Long id) {
        return Resp.ok(orderDetailService.getOrderDetail(id));
    }
  
    @ApiOperation(value = "保存订单详情")
    @PostMapping("/save")
    public Resp<?> saveOrderDetail(@Validated(InsertGroup.class) @RequestBody OrderDetailSaveReq req) {
        return Resp.ok(orderDetailService.saveOrderDetail(req));
    }
  
    @ApiOperation(value = "更新订单详情")
    @PostMapping("/update")
    public Resp<?> updateOrderDetail(@Validated(UpdateGroup.class) @RequestBody OrderDetailSaveReq req) {
        return Resp.ok(orderDetailService.updateOrderDetail(req));
    }
  
    @ApiOperation(value = "批量删除订单详情")
    @DeleteMapping("/batchDelete")
    public Resp<?> batchDeleteOrderDetail(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(orderDetailService.batchDeleteOrderDetail(ids));
    }
  
    @ApiOperation(value = "删除订单详情")
    @DeleteMapping("/delete")
    public Resp<?> deleteOrderDetail(@RequestParam(value = "id") Long id) {
        return Resp.ok(orderDetailService.deleteOrderDetail(id));
    }
}
